package cn.zysheep.user.web;

import cn.zysheep.commons.JWTUtil;
import cn.zysheep.user.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @version v1.0
 * @Author: lyw
 * @Date: 2021/8/13
 */
@Api(tags = "单点登录")
@RestController
@RequestMapping("/user")
public class LoginController {

    @ApiOperation("获取token")
    @PostMapping("login")
    public String login(User user) {
        HashMap<String, Object> map = new HashMap<>(8);
        map.put("user",user);
        String token = JWTUtil.createToken(map);
        return token;
    }
}
